Modified, solved bugs and made it for final state.