some initial changes to make the code less prodecural