Code updated

Coded for issue #1 and #2(first part)
Code Updated

Coded for issue #1 and #2