implemented faster likelihood calculation