cleaned up code for beta