cleaned up code from sugali repo