Added loop and keys handling.