Fixed wrong calculations