Replace my implemenation with Jakes suggestion. Thanks.