fixed issue with placement of "attach" statement