cleaned up and added analytics