I refactored function getFrame. Now the function is so pretty