improved logic and frontend