changed all code to procedural