fixed, but will need to rewrite using oo