fixed order bug, only thing left is better error checking