updated to actually work and not crash out