added legal moves logic