fixed some code placement