rewrite the core script Movement part mostly done