refactor to be a little more as3 ideomatic