tested and working front-end logic