cleaning up code a ton, made it usable for more scenarios