refactored actionscript