Refactoring move checking logic into own function