optimized codes & fixed a scroll bug