applied changes from 51b78609c2304be93f545fcbb7f0b21d4d77ded3