fixed bugs - working for now