updated to work with mega, tested working