Refactors code into isFirstKeyfame.