Merged code - thaminda