Finished debugging better solution