Fixed code. still needs Exception handler