added code (too much to be listed here)