rewrite main function, remove second cross function