acyclified the code as best i could