updated mega code